<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">


<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" th:href="@{/static/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/static/css/thesame.css}" media="all">
    <link rel="stylesheet" th:href="@{/static/css/headCss.css}" media="all">
    <link rel="stylesheet" th:href="@{/static/framework/css/leftSidebar.css}" media="all">
    <link rel="stylesheet" th:href="@{/static/framework/css/rightCon.css}" media="all">
</head>

<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-logo-one blue fb">万里街道沿街商铺</div>
        <ul class="layui-nav layui-layout-left layui-layout-left-color">
            <li class="layui-nav-item">
                <a href="javascript:void(0)" data-id="6" class="current">商铺管理</a>
            </li>
            <li class="layui-nav-item">
                <a href="javascript:void(0)" data-id="19">数据平台</a>
            </li>
            <li class="layui-nav-item">
                <a href="javascript:void(0)" data-id="1">平台管理</a>
            </li>
        </ul>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;"><img th:src="@{/static/framework/img/tx.png}" class="layui-nav-img">&nbsp[[${userName}]]</a>
                <dl class="layui-nav-child">
                    <dd>
                        <a href="">修改密码</a>
                    </dd>
                    <dd>
                        <a href="">安全退出</a>
                    </dd>
                </dl>
            </li>
        </ul>
    </div>
    <div class="layui-side">
        <div class="layui-side-scroll" id="menus">

        </div>
    </div>
    <div class="layui-body mainContent">
        <!-- 内容主体区域 -->
        <iframe th:src="@{/welcome}" class="yjsp_iframe" style="overflow: visible; border: none" width="100%" height="100%" scrolling="no" marginheight="0" marginwidth="0"></iframe>
    </div>
    <!-- <div class="layui-footer">
        © layui.com - 底部固定区域
    </div> -->
</div>
<script th:src="@{/static/js/jquery-3.1.1.min.js}" charset="utf-8"></script>
<script th:src="@{/static/layui/layui.js}" charset="utf-8"></script>
<script th:src="@{/static/framework/js/leftSidebar.js}" charset="utf-8"></script>
<script th:inline="javascript">

    layui.use(['element'], function () {
        var element = layui.element;
    });

    var basePath = [[${#request.getContextPath()}]];

    $(function () {

        $('.layui-layout-left-color li a').on('click', function () {
            $(this).addClass('current').parent().siblings().children().removeClass('current');
            var muneId = $(this).attr('data-id');
            console.log(muneId)
            getMenu(muneId)
        });

        getMenu(6);

    });


    function getMenu(id) {
        var data = {id: id};
        $.ajax({
            url: basePath + "/menu/getMenus",
            type: "get",
            async: false,
            dataType: "json",
            data: data,
            success: function (data) {

                if (data.code == 200) {
                    if (data.data.length > 0) {
                        var str = "<ul class=\"layui-nav layui-nav-tree layui-nav-tree-orgincon menus\" lay-filter=\"test\">";
                        for (var i = 0; i < data.data.length; i++) {
                            str += "<li class=\"layui-nav-item\">";
                            str += "<a href='javascript:;' data-id='"+ data.data[i].url +"' class='" + (data.data[i].sysMenus.length > 0 ? '' : 'menuItem') + "'><img src='img/sidebar_01.png'>" + data.data[i].name + "</a>"
                            if (data.data[i].sysMenus.length > 0) {
                                str += "<dl class=\"layui-nav-child\">"
                                for (var j = 0; j < data.data[i].sysMenus.length; j++) {
                                    str += "<dd><a href='javascript:;' data-id='"+ data.data[i].sysMenus[j].url +"' class='" + (data.data[i].sysMenus.length > 0 ? 'menuItem' : '') + "'>" + data.data[i].sysMenus[j].name + "</a></dd>"
                                }
                            }
                            str += "</li>";
                        }
                        str += "</ul>";
                        $("#menus").html(str);
                    }
                } else {
                    alert(data.msg)
                }
            }
        })

        layui.use('element', function () {
            var element = layui.element;
            element.init();
        });

        $("#menus ul li .menuItem").on('click', moli);

    }

    function moli() {
        var flag = true;
        var url = basePath + $(this).attr('data-id');

        //菜单是否点过
        if (flag) {
            // 添加菜单对应的iframe
            var str = '<iframe src="' + url + '" class="yjsp_iframe" style="overflow: visible; border: none" ' +
                'width="100%" height="100%" scrolling="no" marginheight="0" marginwidth="0"></iframe>'
            $('.mainContent').find('iframe.yjsp_iframe').hide().parents('.mainContent').append(str);
        }
    };
</script>
</body>

</html>